Printing apparatus with a cash drawer control function, and a control method therefor

ABSTRACT

A printing apparatus comprises a real-time command interpreter that functions even when the printing apparatus is off-line, and interprets control commands simultaneously with receiving data. The printing apparatus can therefore output pulses to the external devices even when printing is in progress or the printer is off-line. Such printing apparatus comprises a command detector for directly detecting predetermined command data from the received command data. An external controller controls an external device in accordance with predetermined command data detected by the command detection.

CONTINUING APPLICATION DATA

1. This application is a continuation of Ser. No. 09/361,915, filed Jul.27, 1999, which is a divisional of Ser. No. 08/730,694, filed on Oct.11, 1996, now abandoned, which is a continuation-in-part application ofapplication Ser. No. 08/335,604, filed on Nov. 8, 1994, now U.S. Pat.No. 5,594,653, the contents of each of which are incorporated herein byreference.

BACKGROUND OF THE INVENTION

2. 1. Field of the Invention

3. The present invention relates to a printing apparatus, comprising acash drawer control function and to a control method therefor, andrelates particularly to a printing apparatus capable of controlling thecash drawer irrespective of the status of the printing apparatus. Thepresent invention is therefore particularly effective when used withsystems for processing monetary transactions, such as point-of-sale(POS) terminals and electronic cash registers (ECR).

4. 2. Description of the Related Art

5. In a conventional printing apparatus when continuing the printingoperation is inappropriate, such as when the paper supply is depleted,the printer cover is opened, or an error occurs, conventional printingapparatuses typically stop the printer mechanism containing the printinghead, and bring the interface to the host computer off-line (a logicalnon-connection state) to both protect the printing apparatus and thecommunications data, and assure user safety. Once this off-line state isentered, however, internal control of the printer apparatus stops, andthe data already transferred to the printer apparatus is no longerprocessed. Data is also no longer received by the printer apparatus, andthe printer apparatus cannot receive or process any data output theretoor respond to inquiries from the host computer.

6. The printing apparatus even moves off-line when the form-feed switchis pressed and paper is being advanced, and when the data receivingbuffer storing the received data is full (a buffer full state), and itis difficult to distinguish between these off-line states and off-linestates in which it is inappropriate to continue printing.

7. When the printing apparatus goes off-line, the host computer is nolonger able to send the print data, and the complete system, POS, ECR,or other, comes to a stop. In such a case, the host computer typicallydisplays a message such as “printer problem, please check” on thedisplay device, and the user must manually inspect the printingapparatus and correct the problem leading to the off-line state.However, for many general POS and ECR users, determining the problem isoften difficult and time-consuming.

8. On the other hand, control commands stored in the data receivingbuffer are interpreted in a first-in-first-out (FIFO, the first commandsstored are the first interpreted) order, and the appropriate commandprocess is executed. Control commands that have been processed aredeleted from the data receiving buffer. As a result, as control commandsare successively input from the host computer, the commands are storedone after the other in the data receiving buffer, and processed in orderfrom the oldest control command stored. This creates a time lag betweenoutput of the control command from the host computer and actualexecution of the control command by the printing apparatus.

9. In conventional printing apparatuses handling cut-sheet forms, theprinter mechanism and printer head must be stopped to wait for insertionof the cut-sheet form when the host computer selects a cut-sheet formfor printing. Because internal control of the printing apparatus stopsat this time, the data received from the host computer once thecut-sheet form selection is made is not processed, and there is noresponse from the printing apparatus, until the cut-sheet form isinserted or a predetermined cut-sheet form insertion waiting period iscompleted.

10. As a result, if the user mistakenly selects cut-sheet form printing,the POS/ECR terminal stops processing for the period, thus delayingfurther processing and causing the customer to wait. When the printingapparatus is reset or the power is turned off and then on again, thedata controlling the printing apparatus settings stored in the printingapparatus is lost. This is a significant problem for a printingapparatus used in POS/ECR terminals in financial transaction systems.

11. Errors generated in the printing apparatus include recoverableerrors, such as paper jams in the paper transport path, andnon-recoverable errors, such as problems with the power supply voltagefrom the AC-DC converter and damage to the head temperature detector ofthe print head. The methods of handling recoverable and non-recoverableerrors differ greatly, and it is therefore necessary to distinguishbetween the two; this is, however, difficult for the average user.

12. Furthermore, even if the cause of the error is removed inconventional printing apparatuses, it is necessary to reset the printingapparatus or turn the power off and then on again to escape from theerror state. Both of these operations also destroy the data stored tothat point in the printing apparatus.

13. To minimize the effects of these problems, the host computer in dataprocessing systems using such conventional printing apparatuses adds astatus request command to each line of data instead of batch sendingplural lines of data, and uses the response to determine the currentstatus of the printing apparatus. This, however, adds significantoverhead to the host computer, and leads to reduced throughput in thedata processing system.

14. As a result of the above, stand-alone type dedicated data processingsystems integrating the data entry device, processing device, andprinting apparatus are widely used in conventional POS/ECR systems.Systems connecting a host computer with a printing apparatus using ageneral-purpose interface are not widely used, even though they offerexcellent flexibility, due data reliability problems (i.e., securityissues). To improve data reliability and simultaneously improveoperability (usability), it is desirable to have a data processingsystem whereby the cause of any stop in printing apparatus operation canbe known even while the printing apparatus is in an off-line state, andthe cause of the problem can be quickly corrected.

15. Moreover, conventional POS and ECR systems typically place the cashdrawer in which money is held below the printing apparatus, and issuethe cash drawer open/close signal from the printing apparatus. So-calledterminal printing apparatuses that are connected through some interfaceto a host device to execute a printing process according to the controlcommands received from the host device comprise a means for outputtingthe cash drawer open/close signal for a specified time from the outputport of the specified port number. To reduce the standby time tocompletion of the control commands of the host device, the controlcommands are temporarily stored to a command buffer, and then read andexecuted in the order stored (first-in-first-out).

16. While the command buffer size varies according to the model andapplication of the printing apparatus, the command buffer is often alsoused as a print data buffer, and can therefore generally store a largenumber of control commands. Therefore, when many control commands arestored in the command buffer, significant time may be required to openthe cash drawer even though the cash drawer open command has been sentfrom the host device. More specifically, once a receipt printing orother printing process has been started, monetary transactions such asstoring cash received or making customer change must wait until theprinting process has completed. As a result, the user must wait for anextended period of time, and numerous problems therefore remain forprinting apparatuses used in systems for processing monetarytransactions, such as point-of-sale (POS) terminals and electronic cashregisters (ECR).

17. Faster processing is demanded in printing apparatuses for thePOS/ECR market in recent years. Because transaction processing inparticular requires manual intervention, it is necessary to open thecash drawer immediately as soon as an open request is issued.

OBJECTS OF THE INVENTION

18. Therefore, an object of the present invention is to provide aprinting apparatus whereby the above problems can be solved.

19. It is another object of the present invention to provide a highreliability data processing apparatus.

20. It is a further object of the present invention to reduce theoverhead on the host computer.

21. It is an additional object of the present invention to provide auser-friendly apparatus.

SUMMARY OF THE INVENTION

22. To achieve the above objects, a printing apparatus according to thepresent invention comprises: a receiving means for receiving controlcommands and print data; a storage means for storing at least thecontrol commands; a first control command interpreting means forinterpreting the control commands received by the receiving means; asecond control command interpreting means for reading and interpretingthe control commands stored in the storage means in a first-in-first-out(FIFO) order; and a process execution means for executing thecorresponding processes based on the interpreted results output from thefirst and second control command interpreting means. In this printingapparatus, the process execution means executes the processcorresponding to the interpreted result output from the first controlcommand interpreting means with priority over the process correspondingto the interpreted result output from the second control commandinterpreting means.

23. The process execution means comprises: a first process executionmeans for executing the process corresponding to the control commandbased on the interpreted result output from the first control commandinterpreting means; and a second process execution means for executingthe process corresponding to the control command based on theinterpreted result output from the second control command interpretingmeans; and the first process execution means executes the requiredprocess while interrupting the operation of the second process executionmeans.

24. To enable the host device to determine the cause of the stop inprinting apparatus operation, the printing apparatus of the inventionmay further comprise: a device-condition detection means for detectingthe status of the printing apparatus; a control means for prohibiting orpermitting operation of the received-data storage means according to thedetection result output from the device-condition detection means; and atransmission means for transmitting data to the host device. In thisembodiment, the first process execution means comprises adevice-condition reporting means for reporting the data obtained by thedevice-condition detection means to the transmission means.

25. To enable the host device to recover from errors in the printingapparatus, the printing apparatus of the invention further comprises anerror state flag storage means for storing error state flags setaccording to the occurrence of error states. The printing apparatus inthis case further comprises the second process execution means stoppingprocess execution while the error state flag is set; and the firstprocess execution means comprising an error state flag resetting meansfor resetting the error state flag.

26. To further enable the host device to cancel the cut-sheet forminsertion waiting state of the printing apparatus, the printingapparatus of the invention further comprises a cut-sheet transport meansfor transporting and supplying cut-sheet print media to the printingmeans; a cut-sheet transport control means for waiting until a cut-sheetprint medium is supplied to the cut-sheet transport means, and thenbeginning print medium supply by the cut-sheet transport means; and acut-sheet transport state detection means for detecting the status ofthe cut-sheet transport control means. The first process execution meansin this case comprises a cut-sheet supply wait-state cancellation meansfor canceling operation of the cut-sheet transport control means whenthe cut-sheet supply wait-state of the cut-sheet transport control meansis detected by the cut-sheet transport state detection means.

27. A data processing apparatus according to the invention using aprinting apparatus according to the invention comprises a printingapparatus and a host device. The printing apparatus of this dataprocessing apparatus comprises: a transmission apparatus fortransmitting data to the host device; a receiving means for receivingsaid control commands and print data; a storage means for storing atleast the control commands; a device-condition detection means fordetecting the status of the printing apparatus; a control means forprohibiting or permitting operation of the received-data storage meansaccording to the detection result output from the device-conditiondetection means; a first control command interpreting means forinterpreting the control commands received by the receiving means; asecond control command interpreting means for reading and interpretingthe control commands stored to the received-data storage means in afirst-in-first-out (FIFO) order; a device-condition reporting means forreporting the data obtained by the device-condition detection means tothe transmission means based on the interpreted result of the firstcontrol command interpreting means; and a normal process execution meansfor executing the processes corresponding to the control commands basedon the interpreted results of the second control command interpretingmeans.

28. The device-condition reporting means interrupts operation of thenormal process execution means and executes the process.

29. The host device of this data processing apparatus comprises astorage state detection means for detecting the state of the controlmeans; and a command transmission means for transmitting to the printingapparatus a report device-condition command, the command being a controlcommand requesting transmission of the device condition detection data,and being interpretable by the first control command interpreting means.

30. By means of the invention thus described, it is possible for thehost computer to determine and evaluate the cause of an off-lineprinting apparatus state even after the printing apparatus goesoff-line. The host computer can thus notify the user by means of postinga message, and the system can recover from the off-line state by meansof host computer control if the user corrects the cause of the problem.In addition, when the printing apparatus is in a cut-sheet insertionstandby state, the waiting state can be canceled by the user issuing a‘cancel cut-sheet insertion waiting state command’ from the hostcomputer.

31. When an error occurs in the printing apparatus, it is also possiblefor the host computer to determine what error occurred and where, andwhether the error is recoverable or non-recoverable. When the error isrecoverable, it is also possible to recover from the error and resumeprinting once the user corrects the cause of the error. It is alsopossible to select whether to resume printing from the print line atwhich the error occurred, or to destroy all data already sent and thenrecover from the error.

32. In accordance with another aspect of the present invention, aprinting apparatus comprises a data receiving means for receivingcommand data from a host device, a data storage means for storing thecommand data received by the data receiving means, and a printer controlmeans for reading the command data stored in the data storage means in afirst-in-first-out order and controlling the printing process accordingto the command data. A command detection means is provided for directlydetecting specific command data from the command data received by thedata receiving means, and an external device control means is furtherprovided for controlling an external device connected to the printingapparatus according to the predetermined command data detected by thecommand detection means.

33. As a result of this configuration, it is therefore possible toindependently control an externally connected device as requested by thehost device even when command data for the printing process is stored inthe data storage means.

34. To achieve this, it is possible for the external device controlmeans to control the external device parallel to the printer controlmeans controlling the printing process, to control the external devicewith priority over the printer control means controlling the printingprocess, or to control the external device according to the end of theprinting process when a printing process is being executed by theprinter control means.

35. The process sequence is preferably set appropriately withconsideration to the power supply capacity, the processing capacity ofthe printing apparatus, and other considerations. More specifically, ifthere is sufficient power supply capacity, simultaneously executingcontrol of both the printing apparatus and external device is preferablewith respect to processing speed. On the other hand, temporarilyinterrupting the printing process and controlling the external device ispreferable in applications in which controlling the external device isof higher priority. However, if interrupting the printing process willdegrade the print quality, it is preferable to make controlling theexternal device wait until a break point in the printing process thatwill not result in degraded print quality, such as at the line end.

36. Moreover, the external device control means may comprise one or morepulse generating means for generating pulses of which the pulse width isdetermined according to the predetermined command data. When theexternal device control means thus comprises pulse generating means, itmay further comprise a selection means for selecting one of the two ormore pulse generating means according to the predetermined command data.

37. The external device is more specifically a cash drawer, and theexternal device control means is a drawer control means for controllingcash drawer opening. The data receiving means preferably receives datafrom the host device in data units of a known size, the predeterminedcommand data comprises plural data units, and the command detectionmeans comprises a data counter for counting the number of data units,and a comparison means for comparing the data unit received by the datareceiving means with a command pattern expressing predetermined commanddata according to the data counter value.

38. As a result, the command data received in one-byte units from thehost device can be detected and processed as the data is received. It istherefore not necessary to store a specific number of bytes of commanddata, and the time required for the detection process can be dividedinto small pieces. Therefore, if either the data receiving means or thecommand detection means interrupts printing process control by theprinter control means to at least either receive data from the hostdevice or detect the predetermined command data, the benefits ofdistributing the detection process can be obtained.

39. Other objects and attainments together with a fuller understandingof the invention will become apparent and appreciated by referring tothe following description and claims taken in conjunction with theaccompanying drawings.

BRIEF DESCRIPTION OF THE DRAWINGS

40. In the drawings wherein like reference symbols refer to like parts.

41.FIG. 1 is an overview of a printing apparatus used for describing afirst embodiment of the invention;

42.FIGS. 2A and 2B are cross-sectional views illustrating the operationof the printing apparatus of the present invention;

43.FIG. 3 is a cross-sectional review of the printing unit of theprinting apparatus according to a preferred embodiment of the invention;

44.FIG. 4 is a block diagram of the control circuit achieving thepresent invention;

45.FIG. 5 is a functional block diagram used for describing the firstembodiment of the invention;

46.FIG. 6 is an example of the command used in the first embodiment ofthe invention;

47.FIG. 7 is a flow chart of a control method applied by the printingapparatus according to the first embodiment of the invention;

48.FIG. 8 is a flow chart of a control method applied by the printingapparatus according to a the first embodiment of the invention;

49.FIG. 9 is a flow chart of a control method applied by the printingapparatus according to the first embodiment of the invention;

50.FIG. 10 is a flow chart of a control method applied by the printingapparatus according to the first embodiment of the invention;

51.FIG. 11 a conceptual diagram of the data processing apparatus of theinvention;

52.FIG. 12 is a flow chart of a control method applied by a hostcomputer using a printing apparatus according to a preferred embodimentof the invention;

53.FIG. 13 is a flow chart of a control method applied by a hostcomputer using a printing apparatus according to the first embodiment ofthe invention;

54.FIG. 14 is a circuit block diagram of a control circuit achieving asecond embodiment of the present invention;

55.FIG. 15 is a circuit block diagram of a control circuit used todescribe the second embodiment of the present invention;

56.FIG. 16 is a flow chart showing the sequence of the second embodimentof a control method according to the present invention;

57.FIG. 17 is a flow chart showing the sequence of the second embodimentof a control method according to the present invention; and

58.FIG. 18 is used to describe the preferred command code used in thepresent invention.

DESCRIPTION OF THE PREFERRED EMBODIMENTS

59. First Embodiment

60. A first embodiment of the invention is described below withreference to the accompanying figures.

61. In general, recording paper used in the distribution industry iseither cut-sheet or continuous paper. Cut-sheet paper includesirregularly sized, individual voucher forms called slip paper, andmultiple-part individual voucher forms, called validation paper, of arelatively regular size. Continuous paper includes journal paper forprinting and storing store records, and receipt paper used for simplereceipts.

62.FIG. 1 is an overview of a printing apparatus capable of printing onslip-, journal-, and receipt-type recording paper.

63. As shown in FIG. 1, this printing apparatus comprises printer head1, which is typically a so-called “wire dot head” comprising pluralwires arrayed in a vertical line; and ink ribbon 3. Printer head 1prints while being driven in a reciprocal motion as indicated by arrows1A and 1B.

64. Receipt paper 17 and journal paper 18 are inserted from the back ofthe printer mechanism in roll form, and are fed out from the top asshown in the figure. Slip paper 19 is inserted from the front of theprinter mechanism (arrow 19A), and similarly fed out from the top (arrow19A).

65. Near-end detector 20 for detecting the end of the receipt andjournal paper is also provided. Near-end detector 20 comprises anear-end detecting lever 20 a, which is pushed out in the direction ofarrow 20A by the outside diameter of the roll paper, and a push switch20 b, which is turned on/off by near-end detecting lever 20 a. Theoutside diameter steadily decreases as the end of the roll paperapproaches, and when the core of the roll paper is reached, near-enddetecting lever 20 a rotates in the direction of arrow 20B. This causespush switch 20 b to switch OFF, thus detecting the near-end of thepaper.

66. After printing is completed, receipt paper 17 is cut by cutter unit14, and can be handed to the customer.

67. The printing apparatus is covered by a housing not shown in thefigures; this housing comprises a cover that is not shown and lower case15. Cover detector 21 is an opposed-type photodetector, so calledphoto-interrupter. When the cover is closed, the beam from coverdetector 21 is interrupted, and the cover can be detected to be closed.

68.FIGS. 2A and 2B are cross-sectional views illustrating the operationof the printing apparatus of the present invention during printing tocontinuous and cut-sheet paper. FIG. 2A shows printing on continuouspaper (receipt paper in the figure); FIG. 2B shows printing on cut-sheetpaper (slip paper).

69. The wire pins (not shown in the figure) of printer head 1 areprovided in wire holder 1 a for printing through ink ribbon 3 to receiptpaper 17 against platen 2.

70. Receipt paper 17 is fed by transport rollers 6 a and 6 b passedguide roller 5 and between paper guides 4 a and 4 b. The one transportroller 6 a is connected to a motor or other drive power source (notshown in the figures).

71. Receipt paper detector 12 is a photo-interrupter, lever switch, orother detecting means positioned in the middle of paper guides 4 a and 4b; receipt paper detector 12 is shown as a photo-interrupter in FIG. 2A.

72. When transported by transport rollers 6 a and 6 b, receipt paper 17passes between ink ribbon 3 and platen 2, through presser rollers 7 aand 7 b and cutter unit 14, and is fed out from the top of the printingapparatus. Cutter unit 14 comprises cutter blade 14 a and cutter cover14 b; cutter blade 14 a is driven in the direction of arrow 14A by amotor or other drive power source to cut receipt paper 17.

73. It is to be noted that while receipt paper is shown in the figure,the mechanism used for journal paper is the same except for the cutterunit.

74. When slip paper is printed (FIG. 2B), slip paper 19 is inserted fromslip paper insertion opening 22 at the front of the printing apparatusin the direction of arrow 19A. During roll paper printing, slip feedroller 9 a is pulled in the direction of arrow 10A by plunger 10 asshown in FIG. 2A, and is thus separated from the opposing slip transportroller 9 b. As a result, it is possible to insert slip paper 19. Whenslip paper 19 is inserted, slip paper 19 passes between slip paperguides 11 a and 11 b and abuts slip transport rollers 8 a and 8 b.Whether slip paper has been inserted is detected by slip paper detector13. If paper has been inserted, plunger 10 is released and lever 10 amoves in the direction of arrow 10B, thus causing slip paper 19 to beheld between slip transport rollers 9 a and 9 b.

75. Slip transport rollers 8 b and 9 b are connected to a motor or otherdrive power source not shown in the figures, and slip paper 19 istransported as slip transport rollers 8 b and 9 b and the opposing sliptransport rollers 8 a and 9 a rotate in the direction of arrows 8B, 8A,and 9B, 9A respectively. When printing is completed, slip paper 19 isfed out in the direction of arrow 19A, plunger 10 is driven to separateslip transport roller 9 a from slip transport roller 9 b, and the nextslip paper form can be inserted.

76. Printing on slip paper 19 is possible with receipt paper 17 loadedas shown in the figure, and if carbon paper is added to slip paper 19,the same information can be simultaneously printed on both slip paper 19and receipt paper 17.

77. Note that slip paper detector 13 is a photo-interrupter similar toreceipt paper detector 12.

78. Also shown are lower case 15 and case 16 supporting the headassembly.

79.FIG. 3 is a cross-sectional view of the printing unit of the printingapparatus according to one embodiment of the invention.

80. The method of detecting a loss of synchronism in the head carriagedrive motor is described with reference to FIG. 3.

81. Printer head 1 is fixed on head carriage 1 b together with wireholder 1 a. Head carriage 1 b is driven reciprocally side to side bycarriage transfer belt 32 and carriage drive gears 31 a and 31 b;carriage drive gear 31 a is connected to a head carriage drive motor notshown in the figure. This motor is normally a pulse motor, and is apulse motor in this embodiment. Carriage drive gear 31 a drives rotatingdetector plate 34 via transfer gear 33. Rotating detector plate 34 ispositioned so as to interrupt the detection beam of carriage detector35, which is also a photo-interrupter. Carriage detector 35 detects therotation of rotating detector plate 34 cause by the movement of headcarriage 1 b.

82. Note that rotating detector plate 34 is propeller-shaped, and whenit rotates, the output of carriage detector 35 switches on/off on aregular period. More specifically, when head carriage 1 b is drivenreciprocally by the head carriage drive motor (not shown in the figure),the movement of head carriage 1 b is detected by carriage detector 35.

83. If the receipt paper, journal paper, or slip paper between printerhead 1 and platen 2 is wrinkled and caught between wire holder 1 a andplaten 2, a paper jam occurs. As a result, head carriage 1 b no longertracks rotation of the carriage drive motor, and the carriage drivemotor loses synchronization. This loss of synchronization is detected bycarriage detector 35, and indicated as a “carriage error.”

84. A “home position” for printer head 1 is needed to determine areference point for the print position. Home position detector 36 isalso a photo-interrupter for detecting head carriage lb. Morespecifically, when head carriage 1 b moves to the left, the position atwhich the light beam from home position detector 36 is interrupted isthe reference point for the home position.

85. When printer head 1 moves toward the home position, home positiondetector 36 can detect if printer head 1 does not reach the homeposition due to a paper jam or other factor. A home position erroroccurs when printer head 1 cannot be returned to the home position.

86. A circuit block diagram of the control circuit achieving the presentinvention is shown in FIG. 4.

87. The mechanism of the printing apparatus of the invention asdescribed above is represented as print head 40, motor group 41, andplunger group 42 in FIG. 4; this printer mechanism is driven by printermechanism drive circuit 43. The printer mechanism also comprisescarriage detector 44, home position detector 45, automatic cutterdetector 46, paper detectors 47, and cover detectors 54, each of whichis connected to central processing unit (CPU) 50.

88. Automatic cutter detector 46 detects the position of cutter blade 14a (FIG. 2), drives the cutter blade drive motor (not shown in thefigures), and generates the detector signal at a predetermined position.If a paper jam occurs in the cutter blades, the cutter blades will notmove to the specified position, the detector signal will not be output,and an error is reported. This error is called a “cutter error.” Paperdetectors 47 include near-end detector 20 (FIG. 1), and receipt paperdetector 12 and slip paper detector 13 (FIG. 2).

89. Also connected to CPU 50, which controls the entire printingapparatus, are display device 48, typically an LED unit; panel switch 49for manually advancing the paper; interface 51 for communications withthe host computer; ROM 52 for storing the control program, printcharacter patterns, and other static information; and RAM 53 providingthe receiving buffer, print buffer, and other data buffers. When printdata is input from interface 51, the data is stored to the receivingbuffer of RAM 53, and CPU 50 interprets the data, reads the characterpatterns corresponding to the data code from ROM 52, and drives printhead 40, motor group 41, and plunger group 42 by means of printermechanism drive control circuit 43 to print.

90. When a carriage error, home position error, cutter error, or othererror occurs, CPU 50 can drive display device 48 to notify the user thatan error has occurred.

91.FIG. 5 is a functional block diagram showing the overall mechanism ofthe invention, and the relationships between the various functionalmeans.

92. Host computer 61 transmits the command data, print data, and otherinformation to the printing apparatus. Data receiving means 62 receivesthe data codes from host computer 61 through interface 51, and isrealized as an interrupt sequence activated by interface 51.

93. Real-time command interpreting means 64 interprets and executes thereceived data at the same time it is received, and the process isexecuted during the interrupt sequence together with data receivingmeans 62. Real-time command interpreting means 64 determines whether thereceived data is a real-time control command, and executes the specifiedprocess based on the command if the received data is determined to be areal-time control command.

94. Both real-time command interpreting means 64 and data receivingmeans 62 are realized by a microprocessor in the embodiment. Themicroprocessor functions are both real-time command interpreting means64 and data receiving means 62 during the interrupt sequence. When thehost system sends data to the printer, the interrupt sequence starts.The microprocessor receives the data in the former part of the interruptsequence, and then it starts interpreting the data in the latter part ofthe sequence.

95. All received data passed through real-time command interpretingmeans 64 is stored temporarily in receiving buffer 65. The received databuffered to receiving buffer 65 is read one at a time by commandinterpreter 66, interpreted, and separated into print data and commanddata for controlling the printing apparatus. Command data is applied bycontrol means 68 to execute the settings or operations corresponding tothe command code. Print data is used to store the character patternscorresponding to the data codes to print buffer 67. When printing isthen executed by control means 68, control means 68 reads the printpattern from print buffer 67, and controls printer mechanism functionalunits 70 to print.

96. The RS-232C two-way, serial interface is used as the interface inthis embodiment because of its ability to maintain communications withthe host computer even when the printing apparatus is off-line. With thestandard RS-232C two-way, serial interface, the off-line status ofoff-line devices can be detected by other devices, but because severalbytes of data may be loaded to the communication bus before datatransmission can be stopped, it is necessary for the off-line device toreceive this data even after it moves off-line. It is thereforenecessary for the device to move off-line before the receiving bufferbecomes full, thereby enabling data to be received and stored to thereceiving buffer while the capacity remains even when an error occursand the printing apparatus goes off-line. Data received after thereceiving buffer becomes full, however, is thrown away.

97. With the first embodiment of the invention, however, receivedcommands are interpreted by real-time command interpreting means 64,which is activated by a receive interrupt, before being stored in thereceiving buffer. As a result, the command can be processed even if thetransmitted data is not stored.

98. Real-time commands include commands requesting the status of theprinting apparatus. When this printing apparatus status request isreceived, real-time command interpreting means 64 responds by sendingthe current printing apparatus status to host computer 61 through datatransmission means 63. It remains possible to send the printingapparatus status even when an error occurs because data receiving means62, data transmission means 63, and real-time command interpreting means64 remain functional.

99. Ordinary POS and ECR systems include a cash drawer in which cashpaid by customers and change is stored. In some applications of theprinter of the embodiment, the cash drawer is placed under the printer.Thus, the printer is designed to connect to and drive the cash drawer inaccordance with the command sent from a host device. The printer canalso detect status of the cash drawer, namely open or closed statethrough peripheral device status detector 76.

100. When the received command is determined by command interpreter 66to be a cut-sheet form selection command, control means 68 is notified.Control means 68 thus notifies display means 72 that a cut-sheet formwas selected, displays a prompt that the printing apparatus is waitingfor cut-sheet form insertion, and stores cut-sheet forms information inRAM 53 by means of cut-sheet forms status storage means 79 to indicatethat a cut-sheet form was selected and that the cut-sheet form insertionwait-state was entered. When a cut-sheet form is selected, cut-sheetform detector 47 detects insertion of the cut-sheet form and notifiescontrol means 68 when the form is inserted.

101. Control means 68 monitors the cut-sheet form wait-stateinformation, and stops printing apparatus drive until either thecut-sheet form wait-state information is deleted or cut-sheet forminsertion is detected. By control means 68 stopping printing apparatusoperation, command interpreter 66 also stops without being able toactivate control means 68, but real-time command interpreting means 64continues to operate irrespective of the cut-sheet form wait-state.

102. Real-time commands include commands canceling the cut-sheet formwait-state. When this command is received, the cut-sheet form insertionwait-state information and cut-sheet form selection information storedto RAM 53 are deleted by real-time command interpreting means 64. Whencontrol means 68, which monitors the cut-sheet form insertionwait-state, recognizes that the cut-sheet form insertion wait-stateinformation has been deleted, it cancels the cut-sheet form insertionwait-state, clears print buffer 67, and selects the default paper type.The cut-sheet form insertion wait-state can be canceled by a time-out,and control means 68 thus controls timer 78.

103. If a paper jam or other error occurs during printing, paperfeeding, or paper cutting, an error is detected by error detector 71,control means 68 is notified, and the error information is stored tostatus memory 77. Control means 68 notifies display means 72 that anerror has occurred, an error notice is displayed, and the erroroccurrence is stored as error information to RAM 53 by error statusstorage means 69.

104. Control means 68 monitors the error information, and stopsoperation of the printing apparatus until the error information iscleared. By control means 68 stopping printing apparatus operation,command interpreter 66 also stops without being able to activate controlmeans 68, but real-time command interpreting means 64, which isactivated by a receive interrupt from interface 51, continues to operateirrespective of the error. Because command interpreter 66 is stopped,however, the data received by interface 51 is simply stored to receivingbuffer 65, and control means 68 therefore controls the interface tonotify the host computer that the printing apparatus cannot acceptanymore information (i.e., notifies the host computer that the printingapparatus is now off-line).

105. The real-time commands also include a ‘recover from error’ command.When this command is received, real-time command interpreting means 64deletes the error information stored to RAM 53. When control means 68,which monitors this error status information, recognizes that the errorinformation was deleted, it reactivates the printing apparatus to resumeprinting.

106. Another ‘recover from error’ command is a command to resumeprinting after deleting all previously received data. When this commandis received, receiving buffer 65 and print buffer 67 are cleared byreal-time command interpreting means 64, and the error informationstored in RAM 53 is then deleted.

107. The printing apparatus also goes off-line when a no-paper state isdetected by cut-sheet form detector 47, when an open-cover state isdetected by cover detector 54, and when a manual form feed caused by theform feed switch is detected by switch detector 75. These states arestored to status memory 77, and the information is reported to hostcomputer 61 by real-time command interpreting means 64.

108.FIG. 6 shows the command code for real-time commands in the presentembodiment. Referring to FIG. 6, received data [GS], [R], and [n] areeach one byte long, expressed as 1D, 52, and n in hexadecimal code. [GS]and [R] indicate a real-command; what is executed is selected accordingto the value of [n].

109. The values of [n] and what is executed for each [n] value in thisembodiment are in Table 1. TABLE 1 n What is executed 0 Send printerstatus. 1 Send the cause of the off-line state. 2 Send the cause of theerror. 3 Send the status of the continuous forms detector. 4 Send thestatus of the slip paper detector and slip paper 5 Send the status ofthe validation paper detector and validation paper. 6 Cancel cut-sheetform insertion wait-state. 7 Recover from error (resume printing). 8Recover from error (clear buffers).

110. When [n]=0, the printing apparatus status byte (one byte) shown inTable 2 is sent to the host computer. TABLE 2 n = 0: printer statusValue Bit Function 0 1 0 Reserved Fixed to 0 1 Reserved Fixed to 1 2Drawer kick 0 1 connector 3 On-line/off-line status on-line off-line 4Reserved Fixed to 1 5 Undefined 6 Undefined 7 Reserved Fixed to 0

111. The drawer status, and printing apparatus on-line/off-line statuscan be mined by the host computer based on the printing apparatus statusinformation. When the printing apparatus is off-line, more specificoff-line information can be obtained by setting [n] to 1.

112. When [n]=1, the off-line information byte (one byte) shown in Table3 is sent to the host computer. TABLE 3 n = 1: off-line cause statusValue Bit Function 0 1 0 Reserved Fixed to 0 1 Reserved Fixed to 1 2Cover status Closed Open 3 Form feed by form feed Form feed Form feed inswitch not in progress progress 4 Reserved Fixed to 1 5 No paper:printing Printing not Printing stopped stopped stopped 6 Error status Noerror Error generated 7 Reserved Fixed to 0

113. The host computer can thus evaluate the off-line information, andcan post prompts or other appropriate information to the user based onthe evaluation result. If an error is determined to have occurred,detailed error information can be obtained by resetting [n] to 2.

114. When [n]=2, the error information byte (one byte) shown in Table 4is sent to the host computer. TABLE 4 n = 2: error cause status ValueBit Function 0 1 0 Reserved Fixed to 0 1 Reserved Fixed to 1 2Mechanical error No error Error generated 3 Automatic paper cutter Noerror Error error generated 4 Reserved Fixed to 1 5 Non-recoverableerror No error Error generated 6 Auto-recover error No error Errorgenerated 7 Reserved Fixed to 0

115. The mechanical errors shown in Table 4 refer primarily to errorsdue to a paper jam, but also include carriage errors and home positionerrors. These are further distinguished as paper jams around the printerhead, and automatic paper cutter errors, thereby enabling the hostcomputer to distinguish between paper jams occurring around the printerhead, and in the automatic paper cutter. Based on this determination,the user is appropriately notified using the display means of the hostcomputer where the error occurred, thus facilitating removal of thepaper jam.

116. Printing can be resumed when paper jam errors and similar errorsoccur by removing the paper jam or other error cause. Errors can alsooccur as a result of external power supply problems, damage to theprinter head temperature detector, and other causes making resumption ofprinting difficult, and it is necessary to distinguish thesenon-recoverable errors from recoverable errors (from which printing canbe resumed). Errors other than paper jam errors are therefore identifiedas non-recoverable errors by setting bit 5.

117. When [n]=3, the continuous paper (incl. journal and receipt paper)detector information byte (one byte) shown in Table 5 is sent to thehost computer. TABLE 5 n = 3: continuous paper detector status Value BitFunction 0 1 0 Reserved Fixed to 0 1 Reserved Fixed to 1 2 Journalnear-end Paper No paper detector loaded 3 Receipt near-end Paper Nopaper detector loaded 4 Reserved Fixed to 1 5 Journal end detector PaperNo paper loaded 6 Receipt end detector Paper No paper loaded 7 ReservedFixed to 0

118. When [n]=4, the slip paper detector information byte (one byte)shown in Table 6 is sent to the host computer. TABLE 6 n = 4: slipstatus Value Bit Function 0 1 0 Reserved Fixed to 0 1 Reserved Fixed to1 2 Slip paper selection Selected Not selected 3 Slip paper insertionWaiting Not waiting wait-state 4 Reserved Fixed to 1 5 Slip paperdetector Paper No paper loaded 6 7 Reserved Fixed to 0

119. It is possible to determine from this slip status byte shown inTable 6 whether slip paper is selected or whether continuous orvalidation paper is selected. It is also possible to determine when slippaper is selected whether the printing apparatus is waiting for slippaper insertion, or whether the paper has already been loaded andprinting can proceed.

120. When [n]=5, the validation paper detector information byte (onebyte) shown in Table 7 is sent to the host computer. TABLE 7 n = 5:validation status Value Bit Function 0 1 0 Reserved Fixed to 0 1Reserved Fixed to 1 2 Validation paper Selected Not selected selection 3Validation paper Waiting Not waiting insertion wait-state 4 ReservedFixed to 1 5 Validation paper Paper No paper detector loaded 6 7Reserved Fixed to 0

121. It is possible to determine from this validation status byte shownin Table 7 whether validation paper is selected or whether continuous orslip paper is selected. It is also possible to determine when validationpaper is selected whether the printing apparatus is waiting forvalidation paper insertion, or whether the paper has already been loadedand printing can proceed.

122. The real-time command data receiving means and real-time commandinterpreting means are described below with reference to FIGS. 7 and 8.

123.FIG. 7 shows the printing apparatus initialization process, whichstarts immediately after the power is turned on (step 120). During thisinitialization, the printing mechanism is initialized (step 121), andall information in RAM 53 is initialized, including the cut-sheet formstatus flag, error information, clear-buffer flag, GS flag, and GSR flag(step 122). The clear-buffer flag, GS flag, and GSR flag are used in thereceive interrupt process, and are used by the real-time commandinterpreting means. The real-time command interpreting means is includedin the receive interrupt process caused by the data transfer requirementof the host device. The clear buffers flag is set by the real-timecommand interpreting means and checked by the received data cancellationmeans. The other flags, namely the GS and GSR flags, are used only inthe interrupt process to change the operation state of the real-timecommand interpreting means. Since real-time commands are composed of 3bytes and the receive interrupt process is caused by each bytereception, the real-time interpreting means must change its state inaccordance with the received data. In the final step 124, interfacereceive interrupts are enabled, and the initialization process is ended(step 124).

124.FIG. 8 shows the interface receive interrupt process, as well as thedata receiving means and the real-time command interpreting means. Thedata received from the host computer through the interface is receivedone byte at a time, and the process shown in FIG. 8 is executed forevery byte received. Because the real-time commands comprise threebytes, [GS], [R], and [n], as shown in FIG. 6, the real-time command iscontrolled by the GS flag, which is set when the [GS] byte is received;the GSR flag, which is set when the [R] byte is received when the GSflag is set; and the [n] byte received when the GSR flag is set. Thereis also a clear-buffer flag, which stores whether the buffer is clearedaccording to the value of [n].

125. Data is received and the receive interrupt is activated at step125. At step 126, the received data is read from the interface, and atstep 127 it is determined whether the GSR flag is set. If the GSR flagis set, i.e., if the [GS] and [R] bytes have already been received, thereceived data (“C” in this example) is processed with the value of [n].The GSR flag is cleared at step 136, and the following operation isexecuted based on the value of the received data (C) (step 137).

126. If C=0, the printer information stored in RAM 53 is sent throughthe interface to the host computer by data transmission means 63 (step138).

127. If C=1, the off-line information stored in RAM 53 is sent throughthe interface to the host computer by data transmission means 63 (step139).

128. If C=2, the error information stored in RAM 53 is sent through theinterface to the host computer by data transmission means 63 (step 140).

129. If C=3, the continuous paper information stored in RAM 53 is sentthrough the interface to the host computer by data transmission means 63(step 141).

130. If C=4, the slip information stored in RAM 53 is sent through theinterface to the host computer by data transmission means 63 (step 142).

131. If C=5, the validation information stored in RAM 53 is sent throughthe interface to the host computer by data transmission means 63 (step143).

132. If C=6, it is determined whether the cut-sheet form insertionwait-state is set (step 144), and if so, the cut-sheet form wait flag iscleared (step 145). As shown in FIG. 9, the system can recover from thecut-sheet form insertion wait-state by clearing the cut-sheet form waitflag.

133. If C=8, the clear-buffer flag is set (step 146), and the errorinformation in RAM 53 is cleared (step 147). When the clear-buffer flagis cleared, the receiving buffer and print buffer are both cleared asshown in FIG. 10 after error recovery. If C=7, the error information issimply cleared (step 147).

134. The received data is also temporarily stored in the receivingbuffer even if the data is a real-time command (step 132).

135. If the GSR flag is cleared in step 127, it is determined in step128 whether the GS flag is set. Specifically, if the data has beenreceived through the [GS] byte, the GS flag is set; the GS flag istherefore cleared in step 129, and it is determined whether the receiveddata (C) is the [R] byte (step 129). When the data received immediatelybefore this data is [GS] byte, the [GS] flag has been set in step 135 inthe previous receive interrupt process. In other words, the [GS] flagindicates that the data received immediately before this data is [GS]byte. If C=[R], the GSR flag is set (step 131), and the received data isstored to the receiving buffer (step 132).

136. If the GS flag is cleared in step 128, it is determined in step 134whether the received data (C) is the [GS] code. If C=[GS], the GS flagis set; if not, the data is stored directly to the receiving buffer(step 132), and the receive interrupt process is ended (step 133).

137. The operation of the control means for setting cut-sheet forms isdescribed next with reference to FIG. 9. Shown in FIG. 9 are the processfrom selection of cut-sheet form printing to loading the paper, and theprocess for canceling the cut-sheet form print mode selection.

138. This process starts (step 151) when command interpreter 66determines that the input command is the cut-sheet form selectioncommand, thus causing command interpreter 66 to set the cut-sheet formselection flag, and the cut-sheet form insertion wait flag (step 152).After confirming that mechanical operations are stopped (step 153),cut-sheet form insertion wait timer 78 is activated, and display device48 is set flashing by display means 72 (step 155). In step 156 it isdetermined whether the cut-sheet form insertion wait flag is cleared; ifso, i.e., if the cut-sheet form insertion wait-state is canceled byreal-time command [GS] [R] [6], the cut-sheet form insertion wait timer78 is stopped (step 157), and display device 48 is turned off by displaymeans 72 (step 158). The cut-sheet form selection flag and cut-sheetform insertion wait flag are then cleared (step 159), the papercorresponding to the default paper type setting is set (step 160), andthe cut-sheet form selection process is ended (step 161).

139. If the cut-sheet form insertion wait flag is not cleared in step156, it is determined if the cut-sheet form insertion wait period haspassed (step 162); if the cut-sheet form insertion wait period haspassed, the procedure skips forward to step 158.

140. If the cut-sheet form insertion wait period has not passed in step162, it is determined in step 163 whether the cut-sheet form isinserted. If the cut-sheet form is not inserted, the procedure loopsback to step 156 to determine again whether the cut-sheet form insertionwait flag is cleared. The procedure then determines again whether thecut-sheet form insertion wait flag is cleared, whether the cut-sheetform insertion wait period has passed, and whether the cut-sheet form isinserted.

141. If it is determined in step 163 that the cut-sheet form wasinserted, the cut-sheet form insertion wait timer 78 is stopped (step164), display device 48 is turned on (step 165), and the start-operationstandby period is waited (step 166). If it is determined in step 167that the cut-sheet form is not inserted, the procedure loops back tostep 154, and the above operation is repeated.

142. If it is determined in step 167 that the cut-sheet form is loaded,the cut-sheet form insertion wait flag is cleared (step 168), thecut-sheet form is set to the correct position (step 169), and thecut-sheet form selection process ends (step 161).

143. As described hereinabove, by providing a data receive means and areal-time command interpreting means in the receive interrupt process,it is possible to interpret commands and cancel the cut-sheet formwait-state even when the printing apparatus is stopped due to acut-sheet form insertion wait-state.

144. A means of detecting carriage errors is described below as anembodiment of the invention for detecting errors with reference to FIG.10.

145. The process is started in step 101 by the print command, and theprinting apparatus is initialized for one line in step 102. The line isthen printed from steps 103 to 105. In step 103, one dot row is printedand the printer carriage is advanced one dot row. In step 104, it isdetermined whether a detector pulse was output from carriage detector 35due to carriage movement; the detector pulse is usually output on aregular cycle if the carriage advances normally. In step 105, it isdetermined whether printing the one line is completed; if not, theprocedure loops back to step 103. If the one row is completed, theprocedure then ends at step 106.

146. If the carriage is stopped at this time due to, for example, apaper jam, the detector pulse is not detected at step 104, and theprocedure branches to step 107. The procedure from step 107 is theprocess executed when a carriage error occurs, and the first step (step107) is to notify the host computer that the printing apparatus cannotreceive further communication data, i.e., that it is off-line. That acarriage error has occurred is then stored to RAM 53 in step 108.Because a carriage error is a recoverable error, the error is stored asa recoverable error. The printer mechanism is also stopped in step 109.

147. That an error occurred is then displayed (step 110) by the errordisplay device until it is determined in step 111 that the errorinformation has been deleted. If a real-time command is received, theerror information is deleted, and it is determined in step 112 whetherthe received command indicates a clear buffer operation. If a clearbuffer command has been received, the buffer is cleared in step 113; thebuffers cleared at this time are both the receiving buffer and printbuffer. According to FIG. 8, one of the real-time commands whose code isdescribed as [GS [R] [7] causes the error state flag resetting means toclear the error information without clearing buffers, and anotherreal-time command of [GS] [R] [8] causes the error state flag resettingmeans to do the same thing and the received data cancellation means toclear buffers.

148. A printer mechanism reset operation is then executed in step 114,and the host computer is notified in step 115 that the printingapparatus can again receive data, i.e., is again on-line.

149. By thus including a data receive means and real-time commandinterpreting means within the receive interrupt process, it is possibleto continue interpreting commands when the printing apparatus stops dueto an error, and recovery from errors is therefore also possible.

150. Control of the printing apparatus as seen from the host computer isdescribed next.

151.FIG. 11 is a conceptual diagram of the data processing apparatus ofthe invention in which printing apparatus 300 is connected with hostcomputer 61 by means of an RS-232C communication cable 301. Hostcomputer 61 comprises an internal communication means 304 and an RS-232Cinterface control circuit. A CRT or other display device 302, andkeyboard or other input device 303 are also connected to host computer61.

152.FIG. 12 is a flow chart of the control process of the host computerallowing cancellation of the cut-sheet form wait-state. Printing to slippaper is used as an example of cut-sheet form printing in FIG. 12.

153. When slip paper printing is selected (step 250), the slip paperselection command is output (step 251). Real-time command [GS] [R] [4]is then sent to determine the slip paper status (step 252), and thecorresponding response is received (step 253). This response containsthe information shown in Table 6. Based on this information, the hostcomputer determines whether slip paper was selected (step 254).

154. If slip paper was selected, it is determined based on theinformation from step 253 whether the printing apparatus is waiting forslip paper insertion (step 255). If it is not waiting, it is firstdetermined whether the slip paper is loaded (step 256); if so, the printdata is output (step 257), and slip paper printing is completed (step258).

155. If step 255 returns that the printing apparatus is waiting slippaper insertion, the host computer monitors a specific key in inputdevice 303, e.g., a “cancel slip paper” key, and determines whether thiskey is pressed (step 259). This key is specifically assigned the “cancelslip paper wait-state” function, and is operated by the user.

156. If the key is pressed, the “cancel slip paper wait-state” command[GS] [R] [6] can be output to cancel the slip paper wait-state (step260).

157. It is also possible to terminate slip paper printing (step 259) bymonitoring this key when slip paper is not selected (step 254) and whenthere is no paper (step 256). In these cases, sending the “cancel slippaper wait-state” command [GS] [R] [6] (step 260) will be ignoredbecause the printing apparatus is not in the cut-sheet form insertionwait-state. If the key is not pressed, the process loops back to step252, and the host computer waits for slip paper selection (step 254) oruntil the slip paper is loaded (step 256). In step 254, the host systemconfirms that the slip mode is selected after sending the slip selectioncommand in step 251, because the command may be stored in the commandbuffer and may not have been executed yet. Even if the slip mode has notbeen selected, the slip printing can be canceled by sending GS R 6command to the printer of the embodiment. In that case, the printer willdelete the slip selection command in the command buffer. In step 256,print paper presence is checked only for confirmation. Usually, printpaper absence can hardly be detected in step 256 because the slipwait-state has been judged as false in step 255 indicating that theprint paper has once been detected before the step. The slip absencecondition can occur if the slip paper is pulled out after being insertedonce.

158.FIG. 13 is a flow chart of the printing process in the host computerallowing for error recovery.

159. After printing starts (step 200), the host computer checks whetherthe printing apparatus is still on-line (step 202) after each line ofprint data is sent to the printing apparatus (step 201). In general, itis possible to determine with the RS-232C interface whether thereceiving side (the printing apparatus in this case) is on-line from theCTS (Clear To Send) signal, the DSR (Data Set Ready) signal, or the XOFFcode. If the printing apparatus is on-line, the host computer continuesto send the print data. If there is no more print data (step 203),printing ends (step 204).

160. If in step 202 the printing apparatus is off-line, it is possiblethat an error has occurred in the printing apparatus, or that printinghas been disabled by some other factor (e.g., there is no more printingpaper). To determine whether an error has occurred, the host computersends real-time command [GS] [R] [2] in step 205. The response to thiscommand is received in step 206, and used to determine (in step 207)whether an error occurred.

161. If an error did not occur, the printing apparatus may be off-linefor some reason other than an error; this reason is thereforeinvestigated (step 208), and the appropriate action is taken (step 209).To determine this reason, the host computer outputs real-time command[GS] [R] [1], and receives in response information that, for example,the cover is open or that there is no paper. The host computer can thendisplay a user prompt such as “please close the cover” or “please addpaper” on display device 302 to aid the user in correcting the problem.

162. This sequence is repeated until the printing apparatus comeson-line again (step 210), at which point printing is resumed from step201.

163. If step 207 determines that an error has occurred, it is determinedwhether the error is recoverable (step 211); this determination is basedon the bit 5 value shown in Table 4. If the error is recoverable, theuser is notified that an error has occurred, and can be requested tocheck the expected cause of the error, e.g., a paper jam. The locationof the paper jam can also be reported to the user as being in thecarriage or the automatic paper cutter based on the state of bits 2 and3 in Table 4. After the user corrects the paper jam, the user confirmsthat the cause of the error has been corrected using input device 303(e.g., a keyboard) of the host computer (step 213). Real-time command[GS] [R] [6] or [7] is then output to reset the printing apparatus fromthe error. Because it is possible that the user has not completelycorrected the cause of the error, or that plural errors occurredsimultaneously, the process after error recovery will preferably resumefrom step 205 to check again for errors.

164. If step 211 determines that the error is non-recoverable, there isa problem in the printing apparatus that may not be correctable by theuser. In this case, the user is informed that there is a problem in theprinting apparatus (step 215), and printing is stopped (step 216).

165. In a data processing apparatus such as POS and ECR terminals wheremonetary transactions are handled, data loss and duplication areimpermissible. When an error occurs in the printing apparatus, it isimportant to recover from the error without destroying the data alreadyreceived, and to resume printing. However, to maintain compatibilitywith data processing apparatuses using conventional printingapparatuses, a mode for recovering after deleting the already receiveddata is also enabled, and this mode can be selected by a control commandfrom the host computer. More specifically, in data processingapparatuses using conventional printing apparatuses, the data alreadyreceived is always destroyed after the printing apparatus recovers fromthe error. When the same data is printed after error recovery as beforethe error occurred, a special character is printed at the beginning ofthe line to indicate that the data in that line has been printed twice.A mode for error recovery after destroying the data already received istherefore necessary to maintain compatibility with this operation.

166. By means of the invention thus described, the host computer candetermine why the printing apparatus has gone off-line while theprinting apparatus is off-line.

167. Furthermore, by providing a data receiving means and real-timecommand interpreting means in the receive interrupt process, commandscan be interpreted and recovery from a cut-sheet form insertionwait-state is possible even during the cut-sheet form insertionwait-state.

168. In addition, when the cause of the off-line status is an error, thehost computer can determine whether the error is recoverable; if it isrecoverable, the user can be notified where the error occurred, andprinting can be resumed without destroying the data already receivedonce the cause of the error is corrected.

169. When recovering from an error, it is also possible to choose toresume printing after destroying the data already transmitted to theprinting apparatus, or to resume printing from the line at which theerror occurred.

170. As a result, it is possible to provide a printing apparatusfeaturing high reliability and a high throughput rate; to provide auser-friendly printing apparatus reducing the host computer overhead;and to provide a data processing apparatus using said printingapparatuses for use as a printing apparatus used in monetarytransactions in the distribution industry.

171. Second Embodiment

172. A second embodiment of the invention is described below withreference to the accompanying figures.

173.FIG. 14 is a block diagram of the control circuit achieving thefirst embodiment of the invention.

174. Connected to CPU 550, which controls the entire printing apparatus,are cover sensor 547 for detecting whether the cover is open; panelswitch 549 for manual paper feed control; an interface 551 to the hostcomputer 561; non volatile memory, such as read only memory or ROM 552for storing the control program 52 a, printer character patterns, andother data; and memory, such as random access memory or RAM 553comprising the receive buffer 564 and print buffer 566 shown in FIG. 15.The print data input through interface 551 is stored to the receivebuffer 564 of RAM 553. CPU 550 then interprets this data, reads thecharacter pattern corresponding to the data code from ROM 552, andcontrols printer mechanism control circuit 543 to accomplish theprinting process. More specifically, CPU 550 controls the ink jet heador other print head 540, and motor group 541 for driving print head 540and the recording medium; and drives plungers 542 to hold cut-sheetforms or switches the recording medium transport path as necessary whenthe printing apparatus is designed to print to plural media by means ofprinter mechanism control circuit 543 to print.

175. Pulse generation control commands for requesting supply of acontrol or drive pulse to the cash drawer or other external deviceconnected to the printing apparatus are input through interface 551. Theinput pulse generation control command is interpreted by CPU 550, whichoutputs a pulse from port 556 or port 557 through drawer drive circuit555. The determination of which port to be used for pulse output isspecified using a parameter of the pulse generation control command aswill be described below.

176. An example of a real-time command code executed immediately afterbeing received is shown in FIG. 18. Each of the command code componentsDLE, DC4, and the values n, m, and t in FIG. 18 is one byte expressed inhexadecimal code as 10 h, 14 h, and the hexadecimal value correspondingto n, m, and t.

177. DLE and DC4 identify a real-time command, and select the content(operation) to be executed based on the value of n. When n=1, thecommand is interpreted as a real-time output command, and the aboveprocess is immediately executed. Parameter m defines the port number ofthe pulse output port; t defines the pulse output time.

178.FIG. 15 is a functional block diagram of the overall configurationof the second embodiment of the present invention, and shows therelationship between the various function means. Host computer 561transfers the command data and print data to the printing apparatus.Data receiving means 562 receives the data code from host computer 561through the interface, and is achieved in the second embodiment by meansof an interrupt process started by interface 551. The received data areinterpreted immediately upon being received by real-time commandinterpreting means 563, implemented as part of the interrupt process fordata receiving means 562.

179. Real-time command interpreting means 563 determines whether thereceived data is a real-time control command, and causes the specifiedprocess to be executed according to the command specification if it is areal-time control command. All data received through real-time commandinterpreting means 563 is stored temporarily to receive buffer 564.Command interpreting means 565 reads the received data in afirst-in-first-out sequence in single data units, e.g., one byte at atime, interprets the data code, and discriminates the print data fromthe command data used to set various printing apparatus controlparameters.

180. The interpretation of the data stored in receive buffer 564 bycommand interpreting means 565 is executed in response to a request fromcontrol means 569. When the printing apparatus is in an idle state, forexample, after a printing job is completed, control means 569 repeatschecking whether receive buffer 564 is empty in a normal idling routine.And, if there is data in receive buffer 564, control means 569 causescommand interpreting means 565 to perform the command interpretation asdescribed above.

181. It should be noted that while the data from data receiving means562 in the present embodiment is stored to receive buffer 564 through areal-time command interpreting means, the present invention shall not beso limited. It is also possible, for example, to store the data fromdata receiving means 562 to receive buffer 564 while also passing thedata to real-time command interpreting means 563 in parallel.

182. Command data is processed by control means 569. More specifically,particular settings are made according to the command data, orparticular operations are performed. If the received data is print data,the character pattern is stored to print buffer 566 according to thedata code. When printing is executed by control means 569, the printpattern is read from print buffer 566 to control printing apparatusfunction block 70 and print.

183. As shown in FIG. 14, printing apparatus function block 570comprises primarily printer mechanism control circuit 543, print head540, motor group 551, and plunger group 542.

184. When real-time command interpreting means 563 determines that thereceived data is a real-time pulse output command, the informationindicating that a pulse output request was received is stored to outputrequest storage means 567, which is implemented as a portion of RAM 553.This can be accomplished, for example, by setting a particular flag. Thepulse output time is also stored as information in pulse output timestorage means 568, and is supplied to control means 569. The output portnumber, another parameter of the command, may be separately stored inanother storage means provided in RAM 53 or a respective request flag isprovided for each port number.

185. Control means 569 monitors the real-time pulse output requestinformation by polling output request storage means 567. When areal-time pulse output request is detected, control means 569 outputs apulse according to the information in the storage means to the specifiedport by means of pulse generator 571.

186. When the cover is open or paper is being fed using the papertransport switch, control means 569 enters an off-line state asdescribed above. More specifically, reading and executing commands fromreceive buffer 564 stops to assure operator safety when the printingapparatus cover is open to, for example, supply the paper. Becausereceive buffer 564 may overflow if data continue to be stored to receivebuffer 564 in this state, the printing apparatus notifies the hostdevice that data sent thereafter are not guaranteed to be received. Thisstate is called the “off-line” state.

187. When control means 569 is in the off-line state, control means 569only monitors data input from data receiving means 562, and cannotactivate command interpreting means 565. Real-time command interpretingmeans 563 continues to operate irrespective of the off-line status whilecontrol means 569 monitors data input. The present embodiment is alsoconstructed to output the current pulse driving a solenoid built intothe cash drawer. Pulse generator 571 and printing apparatus functionblock 570 also share the same power supply. If the power supply does nothave sufficient capacity to simultaneously drive both pulse generator571 or the solenoid and printing apparatus function block 570, controlmeans 569 may only be able to drive one of the devices during printingor pulse generation.

188.FIGS. 16 and 17 are flow charts of the preferred printing apparatuscontrol method according to the present invention. FIG. 16 shows thesequence of the receive interrupt process of the interface, and thusshows the data receiving means 62 and real-time command interpretingmeans 563. Data received from the host computer through interface 551 isreceived in data units of a particular size, which is defined as onebyte by way of example only in the present embodiment, and the processshown in FIG. 16 is therefore executed each time one data byte isreceived. The real-time command contains five bytes (DLE, DC4, n, m, andt) as shown in FIG. 18, and is therefore analyzed using a data counterRTC indicating which data byte was received.

189. RTC is cleared to zero before data receiving means 562 startsreceiving the data from the host device in, for example, a power-oninitialization procedure of the printing apparatus.

190. A memory area for storing the port number of the pulse output portdefined by parameter m, and a memory area (568) for storing the pulseoutput time defined by parameter t, are also provided.

191. When the process starts at step 430, data is received and areceiving interrupt is started.

192. The received data is read through the interface at step 431, and itis determined whether the RTC counter is set to 4 in step 432. If theRTC counter is set to 4, i.e., if DLE, DC4, 1, and m have been received,the received data (“C” in this example) is processed as parameter t. TheRTC counter is then cleared in step 433.

193. If the value of the received data (C) is from 1 to 8 (step 434),the pulse output time is stored to a specific address in RAM 553 in step435. Note that all received data is initially stored to the receivebuffer, even real-time commands (step 451).

194. If the value of the received data (C) is outside the range from 1to 8 (step 434), the counter remains cleared and the data is stored toreceive buffer 564 (step 451). Such values are illegal parameters andtherefore prohibit the complete command from being processed. The datais nevertheless stored to receive buffer 564 because it may be part ofthe print data.

195. If the RTC counter does not equal 4 in step 432, it is determinedwhether the RTC counter equals 3 in step 437. More specifically, the RTCcounter is set to 3 if DLE, DC4, and 1 have been received. The RTCcounter is therefore cleared in step 437, and it is determined whetherthe received data (C) is 0 or 1 (step 438). If C is 0 or 1, the RTCcounter is set to 4 (step 439), and the pulse output port numbercorresponding to the value of C is stored to RAM 553 (step 440). Thereceived data is also stored to the receive buffer (step 451). If thevalue of the received data (C) is not 0 or 1 (step 438), the counterremains cleared and the data is stored to the receive buffer (step 451)for the same reason described above.

196. If the RTC counter does not equal 3 in step 436, it is determinedwhether the RTC counter equals 2 in step 441. More specifically, the RTCcounter is set to 2 if DLE and DC4 have been received. The RTC counteris therefore cleared in step 442, and it is determined whether thereceived data (C) is 1 (step 443). If C is 1, the RTC counter is set to3 (step 444), and the received data is stored to the receive buffer(step 451).

197. If the value of the received data (C) is other than 1 (step 443),the counter remains cleared and the data is stored to the receive buffer(step 451).

198. Note that parameter n is used to identify the real-time commandoperation. When n=1, pulse generation processing is accomplished. When ndoes not equal 1, i.e., is a value other than 1, a different real-timeprocess may be executed. Because other real-time processes are notdefined in the present embodiment, such real-time processing does notoccur.

199. If the RTC counter does not equal 2 in step 441, it is determinedwhether the RTC counter equals 1 in step 445. More specifically, the RTCcounter is set to 1 if DLE has been received. The RTC counter istherefore cleared in step 446, and it is determined whether the receiveddata (C) is DC4 (step 447). If C is DC4, the RTC counter is set to 2(step 448), and the received data is stored to the receive buffer (step451).

200. If the value of the received data (C) is other than 14 h (step447), the counter remains cleared and the data is stored to the receivebuffer (step 451).

201. If the RTC counter does not equal 1 in step 445, it is determinedwhether the received data (C) is the DLE code (step 449).

202. If C is DLE, the RTC counter is set to 1 (step 450); if not, thereceived data is stored to the receive buffer (step 451) and the receiveinterrupt process is terminated (step 452).

203. If in step 449 the value of C is other than DLE (10 h), the counterremains cleared and the data is written to the receive buffer (step451).

204. The pulse output control means is described next with reference tothe flow chart in FIG. 17.

205. Control means 569 monitors real-time pulse output requestrepresented by the output request flag stored in output request storage567, and reads the pulse ON time from the pulse output time storagemeans 568 (step 401) when a real-time pulse output request is detected(step 400 returns YES).

206. The pulse output port number is read from the output requeststorage means 567 (step 402), and the pulse is output (step 403 or step404).

207. A timer counting the ON time is activated (step 405), the processwaits for the ON time period (step 406), pulse output to the port isthen stopped (step 407), the OFF time counter is started (step 408), andthe process waits for the OFF time (step 409). When the OFF time haspassed, the output request flag for the port for which an output requestwas issued is cleared (step 410), and the process loops back to step 400to determine whether the next output request was received. If there isno output request, the process continues to look for the next outputrequest.

208. It should be noted that the OFF time in the present embodiment isset to the same time as the ON time specified by command. It is alsopossible, however, to set the OFF time by means of a command parameterusing a process similar to that described above. Note that the OFF timeis set and pulse output requests are effectively prohibited during thisOFF time period to limit the drive duty of the control object. Morespecifically, if an OFF time is not defined and commands are transferredcontinuously, the ON state duty of the control pulse may be excessivelylarge.

209. The pulse output process shown in FIG. 17 in the present embodimentis executed during the standby loop of the printing apparatus controlprogram executed by CPU 550. This loop is therefore not executed duringthe printing process, and the pulse output process is therefore notexecuted. In this case, the pulse output process is executed when oneprinting process is completed and the control program returns to thestandby loop to start the next process.

210. However, if it is necessary to execute the pulse output processirrespective of the printing process, the process can be executed bymeans of an internal interrupt, timer interrupt, or other knowninterrupt process.

211. If there is sufficient power supply capacity, the printing processand pulse output process can be executed in parallel. More specifically,the ON time standby period (step 406) and the OFF time standby period(step 409) in FIG. 17 can be used to easily achieve parallel printingand pulse output processes by means of time-shared printing control.Furthermore, the printing process functions can be handled by printermechanism control circuit 543 using a micro-controller, for example, andthe pulse output process can be executed in parallel by CPU 550.

212. While the invention has been described in conjunction with severalspecific embodiments, it is evident to those skilled in the art thatmany further alternatives, modifications and variations will be apparentin light of the foregoing description. Thus, the invention describedherein is intended to embrace all such alternatives, modifications,applications and variations as may fall within the spirit and scope ofthe appended claims.

What is claimed is:
 1. A printing apparatus comprising: a data receiverto receive command data from a host device; a memory to store thecommand data received by the data receiver; a printer controller to readout the command data stored in the memory in a first-in-first-out orderand control the printing apparatus in accordance with the command data;a command detector to directly detect predetermined command data withinthe command data received by the data receiver; a status data selectorto select one of a plurality of status data in accordance with thepredetermined command data detected by the command detector; and astatus data transmitter to send to the host device the status dataselected by said status data selector in accordance with thepredetermined command data detected by the command detector.
 2. Aprinting apparatus according to claim 1 , wherein each of the pluralityof status data includes common code data embedded therein.
 3. A printingapparatus according to claim 1 , wherein the status data transmittersends to the host device the status data substantially simultaneously tothe printer controller controlling the printing apparatus.
 4. A printingapparatus according to claim 1 , wherein the status data transmittersends to the host device the status data with a higher priority than apriority of the printer controller controlling the printing apparatus.5. A printing apparatus according to claim 1 , wherein the predeterminedcommand data comprise plural data units of a predetermined size, whereinthe command detector comprises: a data counter for counting a number ofdata units, and a comparator to compare the data unit received by thedata receiver with a command pattern representing the predeterminedcommand data in accordance with the data counter.
 6. A printingapparatus according to claim 1 , wherein one of the data receiver andthe command detector, while the printing apparatus control processcontrolled by the printer controller is interrupted, one of (1) receivesdata from the host device, and (2) detects predetermined command datafrom the data received by the data receiver.
 7. A printing apparatusaccording to claim 1 , wherein said status data transmitter combines thestatus data selected by said status data selector with predeterminedcode data.
 8. A method for controlling a printing apparatus comprisingthe steps of: (a) receiving command data from a host device; (b) storingthe command data received in step (a); (c) reading out the command datastored in step (b) in a first-in-first-out order and controlling aprinting apparatus in accordance with the command data; (d) directlydetecting predetermined command data within the command data received instep (a); (e) selecting one of a plurality of status data in accordancewith the predetermined command data detected in step (d); and (f)transmitting the status data selected in step (e) in accordance with thepredetermined command data detected in step (d).
 9. A control methodaccording to claim 8 , wherein each of the plurality of status dataincludes common code data embedded therein.
 10. A control methodaccording to claim 8 , wherein step (f) is executed substantiallysimultaneously to step (c).
 11. A control method according to claim 8 ,wherein step (f) has priority over step (c).
 12. A control methodaccording to claim 8 , wherein in step (d) the predetermined commanddata from the host device comprises plural data units of a predeterminedsize, and wherein step (d) comprises the steps of: counting a number ofdata units; and comparing the data unit received in step (a) with acommand pattern representing the predetermined command data inaccordance with the data count value.
 13. A control method according toclaim 8 , wherein at least one of step (a) and step (d) executes whilestep (c) is interrupted.
 14. A control method according to claim 8 ,wherein said transmitting step further comprises the step of combiningthe status data selected in step (e) with predetermined code data.
 15. Aprinting apparatus comprising: a data receiver to receive command datafrom a host device; a memory to store the command data received by thedata receiver; a printer controller to read out the command data storedin the memory in a first-in-first-out order and control the printingapparatus in accordance with the command data; a command detector todetect predetermined command data within the command data upon receptionof the command data by the data receiver; a status data selector toselect one of a plurality of status data in accordance with thepredetermined command data detected by the command detector; and astatus data transmitter to send to the host device the status dataselected by said status data selector in accordance with thepredetermined command data detected by the command detector.
 16. Aprinting apparatus according to claim 15 , wherein each of the pluralityof status data includes common code data embedded therein.
 17. Aprinting apparatus according to claim 15 , wherein the status datatransmitter sends to the host device the status data in accordance withthe predetermined command data while the printer controller controls theprinting apparatus.
 18. A method for controlling a printing apparatuscomprising the steps of: (a) receiving command data from a host device;(b) storing the command data received in step (a); (c) reading thecommand data stored in step (b) in a first-in-first-out order andcontrolling the printing apparatus according to the command data; (d)detecting predetermined command data within the command data received instep (a) upon reception of the command data in step (a); and (e)selecting one of a plurality of status data in accordance with thepredetermined command data detected in step (d); and (f) transmittingthe status data selected in step (e) in accordance with thepredetermined command data detected in step (d).
 19. A control methodaccording to claim 18 , wherein each of the plurality of status dataincludes common code data embedded therein.
 20. A printing apparatuscomprising: (a) a data receiver to receive command data from a hostdevice; (b) a memory to store the command data received by the datareceiver; (c) a command interpreter to interpret predetermined commanddata within the command data received by the data receiver beforestoring the command data in the memory; (d) a status data selector toselect one of a plurality of status data in accordance with thepredetermined command data interpreted by the command interpreter; (e) astatus data transmitter to send to the host device the status dataselected by said status data selector in accordance with thepredetermined command data interpreted by the command interpreter; and(f) a printer controller to read the command data stored in the memoryin a first-in-first-out order and control the printing apparatus inaccordance with the command data.
 21. A printing apparatus according toclaim 20 , wherein each of the plurality of status data includes commoncode data embedded therein.
 22. A method of controlling a printingapparatus comprising the steps of: (a) receiving command data from ahost device; (b) storing the command data received in step (a); (c)interpreting predetermined command data within the command data receivedin step (a) before storing the command data in step (b); (d) selectingone of a plurality of status data in accordance with the predeterminedcommand data interpreted in step (c); (e) transmitting the status dataselected in step (d) in accordance with the predetermined command datainterpreted in step (c); and (f) reading the command data stored in step(b) to control the printing apparatus.
 23. A control method according toclaim 22 , wherein each of the plurality of status data includes commoncode data embedded therein.
 24. A printing apparatus comprising: a datareceiver to receive command data from a host device; a memory to storethe command data received by the data receiver; a printer controller toread out the command data stored in the memory in a first-in-first-outorder and control the printing apparatus in accordance with the commanddata; a command detector to directly detect predetermined command datawithin the command data received by the data receiver; a status dataselector to select one of a plurality of status data in accordance withthe predetermined command data detected by the command detector; and astatus data transmitter to send to the host device a combination of thestatus data selected by said status data selector and the status datawith predetermined code data in accordance with the predeterminedcommand data detected by the command detector.
 25. A method forcontrolling a printing apparatus comprising the steps of: (a) receivingcommand data from a host device; (b) storing the command data receivedin step (a); (c) reading out the command data stored in step (b) in afirst-in-first-out order and controlling a printing apparatus inaccordance with the command data; (d) directly detecting predeterminedcommand data within the command data received in step (a); (e) selectingone of a plurality of status data in accordance with the predeterminedcommand data detected in step (d); (f) combining the status dataselected in step (e) with predetermined code data; and (g) transmitting,in accordance with the predetermined command data detected in step (d),the status data combined with the predetermined code data in step (f).